#!/bin/bash

exename=$1
inputfile=$2
outputfile=$3
tmpout=$4

./run.sh $1 $2 $3 $4 &

sleep 1
pid=`pgrep run`

if [ "$pid" == "" ]
then
    /usr/bin/diff $tmpout $outputfile
    if [ "$?" = "0" ]; then
    echo '<p style="color:#0F0">accepted </p>'
    else
    echo '<p style="color:#F00">wrong answer </p>'
    fi
else
    kill -9 $pid
    echo '<p style="color:#00F">time out</p>'
fi
